loadstring(exports.dgs:dgsImportFunction())()

local sw,sh = guiGetScreenSize()
local px,py = sw/1366,sh/768

font = dgsCreateFont( ":cmta-pobieraniezasobow/OSB.ttf", 12*px )
font2 = dgsCreateFont( ":cmta-pobieraniezasobow/OSB.ttf", 15*px )
font3 = dgsCreateFont( ":cmta-pobieraniezasobow/OSB.ttf", 24*px )
font4 = dgsCreateFont( ":cmta-pobieraniezasobow/OSB.ttf", 19*px )

function createhud()
local time = getRealTime()
if time.minute >= 60 then time.minute  = time.minute-60; time.hour=time.hour+1 end
local czas = string.format("%02d:%02d",time.hour, time.minute)
local weaponClip = getPedAmmoInClip(getLocalPlayer(), getPedWeaponSlot(getLocalPlayer()))
local weaponAmmo = getPedTotalAmmo(getLocalPlayer()) - getPedAmmoInClip(getLocalPlayer())
consola = dgsCreateLabel(0*px, 0*py, 1366*px, 50*py,"#ff0000✱#ccc000 Consola jest aktywna, wyłącz ją jeśli nie działa GUI #ff0000✱",false)
dgsSetProperty(consola,"alignment",{"center","center"})
dgsSetFont( consola, font2 )
dgsSetProperty(consola,"colorcoded",true)
local rndRect = dgsCreateRoundRect(10,false,tocolor(30,30,30,210)) 
local rndRect2 = dgsCreateRoundRect(0,false,tocolor(30,30,30,210)) 
local lvl = dgsCreateImage(1000*px,20*py,50*px,50*py,rndRect,false)
local main = dgsCreateImage(1055*px,20*py,300*px,50*py,rndRect2,false)
local progresshp = dgsCreateProgressBar(1055*px,50*py,145*px,20*py,false,false,false,false,false,tocolor(255,0,0,255))
dgsProgressBarSetProgress(progresshp, getElementHealth(localPlayer))
local progressarmor = dgsCreateProgressBar(1210*px,50*py,145*px,20*py,false,false,false,false,false,tocolor(128,128,128,255))
dgsProgressBarSetProgress(progressarmor, getPedArmor(localPlayer))
local punkty = dgsCreateLabel(295*px, 5*py, 0*px, 20*py,""..(string.format("%.01d", getElementData(localPlayer,"player:data").points) or 0).." pkt",false,main)
dgsSetProperty(punkty,"alignment",{"right","center"})
dgsSetFont( punkty, font )
local czas = dgsCreateLabel(5*px, 5*py, 0*px, 20*py,czas,false,main)
dgsSetProperty(czas,"alignment",{"left","center"})
dgsSetFont( czas, font )
local poziom = dgsCreateLabel(0*px, 0*py, 50*px, 50*py,""..(getElementData(localPlayer,"player:data").lvl or 1).."",false,lvl)
dgsSetProperty(poziom,"alignment",{"center","center"})
dgsSetFont( poziom, font2 )

local amunicja = dgsCreateLabel(50*px, 5*py, 100*px, 20*py,"| "..(weaponClip + weaponAmmo).."",false,main)
dgsSetProperty(amunicja,"alignment",{"left","center"})
dgsSetFont( amunicja, font )

local bigping = dgsCreateImage(0*px, 0*py, 1366*px, 768*py,"lag.png",false)
dgsSetVisible(bigping,false)

addEventHandler ( "onClientRender", root, function()
    local time = getRealTime()
    if time.minute >= 60 then time.minute  = time.minute-60; time.hour=time.hour+1 end
    local tczas = string.format("%02d:%02d",time.hour, time.minute)
    local weaponClip = getPedAmmoInClip(getLocalPlayer(), getPedWeaponSlot(getLocalPlayer()))
    local weaponAmmo = getPedTotalAmmo(getLocalPlayer()) - getPedAmmoInClip(getLocalPlayer())
    dgsProgressBarSetProgress(progresshp, getElementHealth(localPlayer))
    dgsProgressBarSetProgress(progressarmor, getPedArmor(localPlayer))
    dgsSetText( punkty, ""..(math.floor(getElementData(localPlayer,"player:data").points or 0)).." pkt")
    dgsSetText( poziom, ""..(getElementData(localPlayer,"player:data").lvl or 1).."")
    dgsSetText( czas, tczas)
    dgsSetText( amunicja, "| "..(weaponClip + weaponAmmo).."")
    local ping = getPlayerPing(localPlayer)  
	if getElementData(localPlayer,"player:data").uid then
	if (ping > 500) then
        if dgsGetVisible ( bigping ) == false then  
        dgsSetVisible(bigping,true)   
        dgsBringToFront(bigping,true)     
        end           	
       -- dxDrawText("#ff2828Twój ping jest za wysoki.", 0*px, 0*py, 1360*px, 468*py, tocolor(255, 255, 255, 255), 1, font3, "center", "center", false, true, true,true)
       -- dxDrawText("#808080Gra została zamrożona do czasu, gdy będzie on normalny.", 0*px, 0*py, 1360*px, 548*py, tocolor(255, 255, 255, 255), 1, font4, "center", "center", false, true, true,true)
		toggleAllControls(false)
	else
        if dgsGetVisible ( bigping ) == true then  
        dgsSetVisible(bigping,false)   
        dgsMoveToBack(bigping,true)
        dgsBringToFront(progressarmor,true)
        dgsBringToFront(progresshp,true)
        end       	
		toggleAllControls(true)
	end
    end
    if isConsoleActive() == true then
        if (dgsGetVisible ( consola ) == false) then
            dgsSetVisible(consola,true)
            dgsBringToFront ( consola )
        end
    elseif isConsoleActive() == false then
        if (dgsGetVisible ( consola ) == true) then
            dgsSetVisible(consola,false)
        end
    end



end)
end

addCommandHandler("createhud",function()
    createhud()
end)